class RecentCounter {
    vector<int> a;
public:
    RecentCounter() {

    }
    
    int ping(int t) {
        a.push_back(t);
        int ret=0;
        int left=0,right=a.size()-1;
        while(left<right)
        {
            int mid=left+(right-left)/2;
            if(a[mid]<t-3000)
            {
                left=mid+1;
            }
            else{
                right=mid;
            }
        }
        return a.size()-left;
    }
};

/**
 * Your RecentCounter object will be instantiated and called as such:
 * RecentCounter* obj = new RecentCounter();
 * int param_1 = obj->ping(t);
 */
